import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/qa_list_entity.dart';

QaListEntity $QaListEntityFromJson(Map<String, dynamic> json) {
  final QaListEntity qaListEntity = QaListEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    qaListEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    qaListEntity.msg = msg;
  }
  final List<QaListData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<QaListData>(e) as QaListData).toList();
  if (data != null) {
    qaListEntity.data = data;
  }
  return qaListEntity;
}

Map<String, dynamic> $QaListEntityToJson(QaListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension QaListEntityExtension on QaListEntity {
  QaListEntity copyWith({
    int? code,
    String? msg,
    List<QaListData>? data,
  }) {
    return QaListEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

QaListData $QaListDataFromJson(Map<String, dynamic> json) {
  final QaListData qaListData = QaListData();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    qaListData.id = id;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    qaListData.title = title;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    qaListData.content = content;
  }
  final int? sortId = jsonConvert.convert<int>(json['sort_id']);
  if (sortId != null) {
    qaListData.sortId = sortId;
  }
  final String? platform = jsonConvert.convert<String>(json['platform']);
  if (platform != null) {
    qaListData.platform = platform;
  }
  return qaListData;
}

Map<String, dynamic> $QaListDataToJson(QaListData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['title'] = entity.title;
  data['content'] = entity.content;
  data['sort_id'] = entity.sortId;
  data['platform'] = entity.platform;
  return data;
}

extension QaListDataExtension on QaListData {
  QaListData copyWith({
    int? id,
    String? title,
    String? content,
    int? sortId,
    String? platform,
  }) {
    return QaListData()
      ..id = id ?? this.id
      ..title = title ?? this.title
      ..content = content ?? this.content
      ..sortId = sortId ?? this.sortId
      ..platform = platform ?? this.platform;
  }
}